<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\AdminBaseController;
use App\Services\Admin\AdminRoutesService;

class AdminRoutesController extends AdminBaseController
{
    protected $services = null;

    public function __construct(AdminRoutesService $services)
    {
        parent::__construct();

        $this->services = $services;
    }

    /** 获取用户前端路由 */
    public  function userRoutes()
    {
        //获取用户权限菜单
        /** @var AdminRoutesService $app */
        $app = app(AdminRoutesService::class);
        $data = $app->getUserRoutes();
        if(is_array($data)){
            tree($data);
        }
        return $this->success($data);
    }

    /** 获取用户前端路由 */
    public  function routes()
    {
        //获取用户权限菜单
        /** @var AdminRoutesService $app */
        $app = app(AdminRoutesService::class);
        $data = $app->getRoutes();
        tree($data);
        return $this->success($data);
    }


    public function power()
    {

        $result = $this->services->setPower();
        if ($result) {
            return $this->success();
        } else {
            return $this->failure($this->services->getError("Error"));
        }

    }





}
